package com.boarsoft.boar.soagov.nexus.action;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.ParentPackage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import com.boarsoft.boar.entity.SoaNexus;
import com.boarsoft.boar.soagov.com.ComBiz;
import com.boarsoft.boar.soagov.nexus.NexusBiz;
import com.boarsoft.boar.soagov.svc.SvcBiz;
import com.boarsoft.common.Authorized;
import com.boarsoft.common.Util;
import com.boarsoft.common.action.PageAction;
import com.boarsoft.common.dao.PagedResult;
import com.boarsoft.common.util.JsonUtil;

@SuppressWarnings("serial")
@Component
@Scope("prototype")
@ParentPackage("default-package")
@Namespace(value = "/nexus")
public class NexusAction extends PageAction {
	@Autowired
	private NexusBiz nexusBiz;
	@Autowired
	private ComBiz comBiz;
	@Autowired
	private SvcBiz svcBiz;
	//
	private String id;
	private String objId0;
	private String objType0;
	private String objVer0;
	private String objId1;
	private String objType1;
	private String objVer1;
	private String key;
	private String way;
	private short async;
	private String memo;

	@Action("list")
	@Authorized(code = "nexus.list")
	public void list() {
		PagedResult<SoaNexus> pr = nexusBiz.list(objType0, objId0, objType1, objId1, key,
				orderBy, pageNo, pageSize);
		writeReply(true, JsonUtil.from(pr));
	}

	@Action("save")
	@Authorized(code = "nexus.save")
	public void save() {
		SoaNexus o;
		if (Util.strIsEmpty(id)) {
			o = new SoaNexus();
			o.setObjId0(objId0);
			o.setObjType0(objType0);
			o.setObjVer0(objVer0);
			o.setObjId1(objId1);
			o.setObjType1(objType1);
			o.setObjVer1(objVer1);
		} else {
			o = nexusBiz.get(id);
		}
		o.setWay(way);
		o.setAsync(async);
		o.setMemo(memo);
		nexusBiz.save(o);
		writeReply();
	}

	@Action("delete")
	@Authorized(code = "nexus.delete")
	public void delete() {
		nexusBiz.delete(id);
		writeReply();
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public NexusBiz getNexusBiz() {
		return nexusBiz;
	}

	public void setNexusBiz(NexusBiz nexusBiz) {
		this.nexusBiz = nexusBiz;
	}

	public String getComId0() {
		return objId0;
	}

	public void setComId0(String objId0) {
		this.objId0 = objId0;
	}

	public String getComId1() {
		return objId1;
	}

	public void setComId1(String objId1) {
		this.objId1 = objId1;
	}

	public String getKey() {
		return key;
	}

	public void setKey(String key) {
		this.key = key;
	}

	public ComBiz getComBiz() {
		return comBiz;
	}

	public void setComBiz(ComBiz comBiz) {
		this.comBiz = comBiz;
	}

	public SvcBiz getSvcBiz() {
		return svcBiz;
	}

	public void setSvcBiz(SvcBiz svcBiz) {
		this.svcBiz = svcBiz;
	}

	public short getAsync() {
		return async;
	}

	public void setAsync(short async) {
		this.async = async;
	}

	public String getMemo() {
		return memo;
	}

	public void setMemo(String memo) {
		this.memo = memo;
	}

	public String getObjId0() {
		return objId0;
	}

	public void setObjId0(String objId0) {
		this.objId0 = objId0;
	}

	public String getObjId1() {
		return objId1;
	}

	public void setObjId1(String objId1) {
		this.objId1 = objId1;
	}

	public String getWay() {
		return way;
	}

	public void setWay(String way) {
		this.way = way;
	}

	public String getObjType0() {
		return objType0;
	}

	public void setObjType0(String objType0) {
		this.objType0 = objType0;
	}

	public String getObjType1() {
		return objType1;
	}

	public void setObjType1(String objType1) {
		this.objType1 = objType1;
	}

	public String getObjVer0() {
		return objVer0;
	}

	public void setObjVer0(String objVer0) {
		this.objVer0 = objVer0;
	}

	public String getObjVer1() {
		return objVer1;
	}

	public void setObjVer1(String objVer1) {
		this.objVer1 = objVer1;
	}
}